<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

</body>
<script>
  function f1(x,y){
    x = x || 1;
    y = y || 1;
    console.log(x+y)
  }
  f1(3,5);
  f1("3","5");
  f1(0,0);
  console.log("----")
  /*es6中支持给函数的参数列表直接赋值，表示该参数的默认值，默认值只有在null或者undefined时生效*/
  function f2(x=1,y=2){
    console.log(x+y)
  }
  f2(8,5);
  f2();
  f2(0,0)


  function success(res={}){
    if (res.code === 200){
      console.log(res.msg)
    }
  }

  function suc({code=200,msg='hhhhh'}={}){
    if (code === 200){
      console.log(msg)
    }
  }

  success({code:200,msg:"success"});
  success();
  suc({code:200});
  suc();

</script>
</html>
